import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import tailwindcss from '@tailwindcss/vite'
import { vitePluginForArco } from '@arco-plugins/vite-vue'
// import AutoImport from "unplugin-auto-import/vite";
// import Components from "unplugin-vue-components/vite";
// import { ArcoResolver } from "unplugin-vue-components/resolvers";
import path from 'node:path'
import autoprefixer from 'autoprefixer'
import vueJsx from '@vitejs/plugin-vue-jsx'

// https://vite.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    },
    extensions: ['.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
  },
  css: {
    preprocessorOptions: {
      less: {
        modifyVars: {
          'arcoblue-6': '#ee6825'
        },
        javascriptEnabled: true
      }
    },
    postcss: {
      plugins: [autoprefixer()]
    }
  },
  plugins: [
    vue({
      template: {
        transformAssetUrls: {
          include: ['svg'] // 允许SVG作为组件
        }
      }
    }),
    tailwindcss(),
    vitePluginForArco({
      style: true
    }),
    // AutoImport({
    //   resolvers: [ArcoResolver()],
    // }),
    // Components({
    //   resolvers: [
    //     ArcoResolver({
    //       sideEffect: true,
    //       importStyle: "less",
    //     }),
    //   ],
    // }),
    vueJsx()
  ],
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:8083',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '')
      }
    }
  }
})
